<?php
class  ApiCenter_VendorsApi_Model_Api2_Announcement_Rest extends ApiCenter_VendorsApi_Model_Api2_Announcement{
 
    
    
    
    protected  function _getCollectionForRetrieve($type=false){
        
        if(!$type){
            //查询公告列表
            /** @var $collection ApiCenter_VendorsApi_Model_Resource_Mysql4_Address_Collection */  
            $collection =   Mage::getResourceModel("vendorannouncement/announcement_collection");
            
            $collection ->getSelect()
            ->joinLeft(array("k"=>"rumall_vendor_announcement_type"),
                "k.type_id = main_table.type_id",
                array("type_name"=>"k.name")
            );
            $this->_applyCollectionModifiers($collection);
            return $collection;
        }else{
            //查询主题列表
            $collection =   Mage::getResourceModel("vendorannouncement/type_collection");
            return $collection;
        }
    
    }
    
    protected  function _getForRetrieve($aid){
        
        $collection =   Mage::getResourceModel("vendorannouncement/announcement_collection");
        $collection->addFieldToFilter("id",$aid);
        $collection->addFieldToFilter("status","1");
       $collection ->getSelect()
                          ->joinLeft(array("k"=>"rumall_vendor_announcement_type"), 
                             "k.type_id = main_table.id",
                              array("type_name"=>"k.name")
                             );
        $dataInfo = $collection ->getFirstItem();
         return $dataInfo;
    }
}